package com.relax.netty.zerocopy;

import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.Socket;

public class OldClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("localhost", 8899);
        final FileInputStream fileInputStream = new FileInputStream("/Users/zoeychen/Downloads/DingTalk_v4.7.15.7.dmg");
        final DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
        byte[] bytes = new byte[1024];
        long read = 0;
        long total = 0;
        long timeStart = System.currentTimeMillis();
        while (read != -1) {
            read = fileInputStream.read(bytes);
            total += read;
            dataOutputStream.write(bytes);
        }
        System.out.println("发送的总字节数:" + total + ",耗时:" + (System.currentTimeMillis() - timeStart));
        fileInputStream.close();
        dataOutputStream.close();
    }
}
